package fr.alma.domo.music.impl;

import org.oasisopen.sca.annotation.Reference;
import org.oasisopen.sca.annotation.Service;

import fr.alma.domo.model.AbstractService;
import fr.alma.domo.music.ExecutionService;
import fr.alma.domo.music.PlayerHPCollaboration;
import fr.alma.domo.music.rc.HP;
import fr.alma.domo.music.rc.Player;
import fr.alma.domo.svc.CollaborationHandler;

@SuppressWarnings("serial")
@Service(ExecutionService.class)
public class ExecutionServiceImpl extends AbstractService  implements ExecutionService{
	private static String PHP_SCHEMA = null;
	
	private CollaborationHandler collaborationHandler;
	
	public ExecutionServiceImpl() {
		super("ExecutionService");
	}

	@Reference(name="CollaborationHandler")
	public void setCollaborationHandler(CollaborationHandler ch){
		this.collaborationHandler = ch;
		PHP_SCHEMA = this.collaborationHandler.createSchema(PlayerHPCollaboration.class);
	}
	
	@Override
	public void execute(Player player, HP hp) {
		player.setAttribute(Player.SERVICE_NAME, PlayerHPCollaboration.PLAYER_SERVICE_NAME);
		hp.setAttribute(HP.SERVICE_NAME, PlayerHPCollaboration.HP_SERVICE_NAME);
		collaborationHandler.createInstance(PHP_SCHEMA, player,hp);
	}

}
